@echo off
chcp 65001 > nul
title Start UC System Services

echo ====================================
echo   Start AI + Backend + Frontend
echo ====================================
echo.

echo [1/3] Stop existing services...
taskkill /f /im node.exe 2>nul
taskkill /f /im python.exe 2>nul
timeout /t 2 /nobreak > nul

echo.
echo [2/3] Start three service windows...

echo Starting AI Service (Port 5001)...
start "AI-Service-5001" cmd /k "cd /d d:\VSCodeProjects\UC_System\endo_sight_uc_ai && python inference_server.py"

echo Starting Backend API (Port 4000)...
start "Backend-API-4000" cmd /k "cd /d d:\VSCodeProjects\UC_System && node start_backend_alternative.js"

echo Starting Frontend Web (Port 8102)...
start "Frontend-Web-8102" cmd /k "cd /d d:\VSCodeProjects\UC_System\endo_sight_uc_web && npm run dev"

echo.
echo [3/3] Wait for services to start...
timeout /t 10 /nobreak > nul

echo.
echo ====================================
echo     All Services Started!
echo ====================================
echo.
echo Access URLs:
echo - Frontend: http://localhost:8102
echo - Backend API: http://localhost:4000/api/health
echo - AI Service: http://localhost:5001/health
echo.
echo Tips:
echo - Three CMD windows opened
echo - Each window runs one service
echo - Close window to stop service
echo.
echo System startup complete!
echo.
pause
